package level.editor.view.action.frame;

import java.awt.Point;
import java.awt.event.ActionEvent;
import java.beans.PropertyVetoException;

import javax.swing.ImageIcon;

import level.editor.control.tile.TileControl;
import level.editor.view.action.ActionConstants;
import level.editor.view.action.DesktopAction;
import level.editor.view.desktop.Desktop;
import level.editor.view.frame.InternalFrame;

public class AddTileControlAction extends DesktopAction
{
	public AddTileControlAction(Desktop desktop)
	{
		super(FrameConstants.TILE_TOOL, desktop, ActionConstants.ICON_DIR
				+ "tile.png");
	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		InternalFrame frame = new InternalFrame(FrameConstants.TILE_TOOL,
				new ImageIcon(ActionConstants.ICON_DIR + "tile.png"));
		frame.setOrigin(new Point(100, 40));
		desktop.add(frame, InternalFrame.Z_ORDER);
		frame.addItem(new TileControl(desktop.getMainTabbed()));
		try
		{
			frame.setSelected(true);
		}
		catch (PropertyVetoException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

}
